//给定两个字符串 s1 和 s2，请编写一个程序，确定其中一个字符串的字符重新排列后，能否变成另一个字符串。 
//
// 示例 1： 
//
// 输入: s1 = "abc", s2 = "bca"
//输出: true 
// 
//
// 示例 2： 
//
// 输入: s1 = "abc", s2 = "bad"
//输出: false
// 
//
// 说明： 
//
// 
// 0 <= len(s1) <= 100 
// 0 <= len(s2) <= 100 
// 
// Related Topics 数组 字符串


package leetcode.editor.cn;

/**
 * 双百通过
 */
class A面试题0102CheckPermutationLcci {
    public static void main(String[] args) {
        Solution solution = new A面试题0102CheckPermutationLcci().new Solution();
        System.out.println("佛祖保佑");
        System.out.println("\uD80C\uDC09\uD80C\uDC02\uD80C\uDC03\uD80C\uDC10");

    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean CheckPermutation(String s1, String s2) {
            if (s1.length() != s2.length()) {
                return false;
            }
            int[] s1Sum = new int[256];
            int[] s2Sum = new int[256];
            for (int i = 0; i < s1.length(); i++) {
                s1Sum[s1.charAt(i)]++;
                s2Sum[s2.charAt(i)]++;
            }
            for (int i = 0; i < s1Sum.length; i++) {
                if (s1Sum[i] != s2Sum[i]) {
                    return false;
                }
            }
            return true;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}
